'use strict';

const Service = require('egg').Service;

class HomeService extends Service {
    //新增
    async put(title,author,num,status,important,time) {
        await this.app.mysql.query('insert into list (create_time,title,author,important,num,status) values (?,?,?,?,?,?)',[time,title,author,important,num,status])
    }
    //修改
    async update(title,author,num,status,important,id){
        await this.app.mysql.query('update list set title=?,author=?,important=?,num=?,status=? where id=?',[title,author,important,num,status,id])
    }
    //删除
    async del(id){
        await this.app.mysql.query('delete from list where id=?',[id])
    }
    //查询
    async booklist(start,count){
        return await this.app.mysql.query(`select * from list limit ${start},${count}`)
    }
    async total(){
        return await this.app.mysql.query('select count(*) from list')
    }
}

module.exports = HomeService;
